package com.mlog.njyjy.ndop.msg.common.domain;

import com.google.gson.annotations.JsonAdapter;
import com.jfinal.plugin.activerecord.Model;
import com.mlog.njyjy.ndop.msg.common.domain.core.Timeable;
import com.mlog.njyjy.ndop.msg.common.support.Constants;
import com.mlog.njyjy.ndop.share.sql.annotation.Column;
import com.mlog.njyjy.ndop.share.sql.annotation.Id;
import com.mlog.njyjy.ndop.share.sql.annotation.Table;
import com.mlog.njyjy.ndop.share.sql.annotation.TableUnique;
import com.mlog.njyjy.ndop.msg.common.support.LocalDateTimeTypeAdapter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * <p>
 * 消息流程监控表
 * </p>
 *
 * @author zyz
 * @version v1.0, 2020/8/12
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Table(prefix = Constants.TBL_MSG_PREFIX,
        uniques = {@TableUnique(columns = {"nodeItemId"})},
        comment = "消息流程节点监控表")
public class DelayMonitor extends Model<DelayMonitor> implements Timeable {

    @Id
    private Long id;

    @Column(nullable = false, comment = "流程节点id")
    private Long nodeItemId;

    @Column(nullable = false, comment = "业务提醒时间")
    @JsonAdapter(LocalDateTimeTypeAdapter.class)
    private LocalDateTime remindAt;

    @Column(nullable = false, comment = "报警时间")
    @JsonAdapter(LocalDateTimeTypeAdapter.class)
    private LocalDateTime alarmAt;

    @Column(nullable = false, comment = "结束时间")
    @JsonAdapter(LocalDateTimeTypeAdapter.class)
    private LocalDateTime endAt;

    @Column(comment = "首发偏移量（单位：分钟）")
    private int startOffset;

    @Column(comment = "一级报警阈值（延迟）（单位：分钟）")
    private int primaryAlarmThreshold;

    @Column(comment = "二级报警阈值（严重延迟）（单位：分钟）")
    private int secondaryAlarmThreshold;

    @Column(nullable = false, comment = "状态 0：不启用 1：启用")
    private int status;

    @Column(updatable = false)
    private LocalDateTime createAt;

    private LocalDateTime updateAt;
}
